import org.apache.hadoop.io.WritableComparable;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class keyUtil implements WritableComparable<keyUtil> {
    private long keyvalue; //记录成绩
    public long getKeyvalue(){return this.keyvalue;}
    keyUtil(){}
    keyUtil(Integer keyid){
        this.keyvalue = keyid;
    }

    //writablecomparable实现compareTo用于比较大小，返回-1，0，1
    @Override
    public int compareTo(keyUtil o) {
        return this.keyvalue >o.getKeyvalue()?-1:1;
    }

    //toString才能返回正确的key，不然会返回内存地址
    @Override
    public String toString() {
        return keyvalue+" ";
    }

    //序列化
    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeLong(keyvalue);
    }
    //反序列化
    @Override
    public void readFields(DataInput dataInput) throws IOException {
            keyvalue = dataInput.readLong();
    }

}
